﻿using Base.FileGateway.Helper;
using Base.FileGateway.Interface;
using Base.FileGateway.Model;
using Base.FileGateway.PdfConvert.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;

namespace Base.FileGateway.Api
{
    internal class UserPdfFileController : ApiController
    {
        private readonly IUserPdfFileService _Service;

        public UserPdfFileController ( IUserPdfFileService service )
        {
            this._Service = service;
        }

        [ApiRouteName("/file/pdf/convert")]
        public PdfCovertRes Convert ( PdfUpArg arg )
        {
            return this._Service.Apply(new PdfArg
            {
                FileId = arg.FileId,
                UserId = this.UserState.ToEmpId(),
                UserType = this.UserState.ToUserType(),
                DirKey = arg.DirKey,
                LinkBizPk = arg.LinkBizPk,
                Tag = arg.Tag
            });
        }
        [ApiRouteName("/file/pdf/get")]
        public PdfCovertRes GetResult ( [NullValidate("file.task.id.null")][LenValidate("file.task.id.len", 32)] string taskId )
        {
            return this._Service.GetResult(taskId);
        }
    }
}